<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\enum;

class CdcEnum
{
    /**
     * @var int 账户类型
     */
    public const TASK_TYPE_ACCOUNT = 1;

    /**
     * @var int 视频类型
     */
    public const TASK_TYPE_VIDEO = 2;

    /**
     * @var int 图片类型
     */
    public const TASK_TYPE_PICTURE = 3;

    /**
     * @var int 账户类型
     */
    public const STAT_ACCOUNT = 0;

    /**
     * @var int 客户类型
     */
    public const STAT_CLIENT = 1;

    /**
     * @var int ks用户类型
     */
    public const STAT_KS_USER_VIDEO = 2;

    /**
     * @var int 统计类型-KsUserId
     */
    public const STAT_KS_USER_PICTURE = 2;

    /**
     * @var int 视频类型
     */
    public const STAT_VIDEO = 3;

    /**
     * @var int 图片类型
     */
    public const STAT_PICTURE = 3;

    /**
     * @var int 日志删除类型-删除自身日志
     */
    public const LOG_DELETE_SELF = 0;

    /**
     * @var int 日志删除类型-删除素材
     */
    public const LOG_DELETE_MATERIAL = 1;

    /**
     * @var int 统计类型-产品
     */
    public const STAT_PRODUCT = 4;

    /**
     * @var int 类型-月份
     */
    public const STAT_MONTH = 5;

    /**
     * @var int 类型-客户媒体月汇总
     */
    public const STAT_CLIENT_MEDIA = 6;

    /**
     * @var string 回溯锁
     */
    public const CDC_TASK_LOCK = 'cdc:recall:task:lock:%d:' . RedisEnum::REDIS_STRING;

    /**
     * @var array 素材修复列表
     */
    public const CDC_MATERIAL_REPAIR_LIST = 'cdc:material:repair:task:%d:%d:' . RedisEnum::REDIS_LIST;

    /**
     * @var array 账户切换数据修复
     */
    public const CDC_ACCOUNT_CHANGE_LIST = 'cdc:account:change:' . RedisEnum::REDIS_LIST;

    /**
     * @var array 汇总类型模型列表
     */
    private const CLASS_LIST = [
        CommonEnum::OE_MEDIA => [
            'report' => [
                self::TASK_TYPE_ACCOUNT => '\app\model\mongo\MongoOeAccountDayReportModel',
                self::TASK_TYPE_VIDEO => '\app\model\mongo\MongoOeVideoDayReportModel',
                self::TASK_TYPE_PICTURE => '\app\model\mongo\MongoOePicDayReportModel',
            ],

            'stat' => [
                self::STAT_ACCOUNT => '\app\model\mongo\MongoOeAccountVideoStatModel',
                self::STAT_CLIENT => '\app\model\mongo\MongoOeClientVideoStatModel',
                self::STAT_VIDEO => '\app\model\mongo\MongoOeVideoStatModel',
            ],

            'pic_stat' => [
                self::STAT_ACCOUNT => '\app\model\mongo\MongoOeAccountPicStatModel',
                self::STAT_CLIENT => '\app\model\mongo\MongoOeClientPicStatModel',
                self::STAT_PICTURE => '\app\model\mongo\MongoOePicStatModel',
            ],

            'account_stat' => [
                self::STAT_CLIENT => '\app\model\mongo\MongoClientAccountTypeDayStatModel',
                self::STAT_PRODUCT => '\app\model\mongo\MongoProductAccountTypeDayStatModel',
                self::STAT_MONTH => '\app\model\mongo\MongoClientMonthStatModel',
                self::STAT_CLIENT_MEDIA => '\app\model\mongo\MongoClientMediaMonthStatModel',
            ],

            'sync' => [
                'account' => '\app\model\mongo\MongoOeAccountSyncLogModel',
                'video' => '\app\model\mongo\MongoOeVideoSyncLogModel',
                'pic' => '\app\model\mongo\MongoOePicSyncLogModel',
            ],

            'sync_append' => [
                'video' => '\app\model\mongo\MongoOeVideoAppendSyncLogModel',
                'pic' => '\app\model\mongo\MongoOePicAppendSyncLogModel',
            ],

            'info' => [
                'video' => '\app\model\mongo\MongoOeVideoModel',
                'pic' => '\app\model\mongo\MongoOePicModel',
            ],
        ],

        CommonEnum::KS_MEDIA => [
            'report' => [
                self::TASK_TYPE_ACCOUNT => '\app\model\mongo\MongoKsAccountDayReportModel',
                self::TASK_TYPE_VIDEO => '\app\model\mongo\MongoKsVideoDayReportModel',
                self::TASK_TYPE_PICTURE => '\app\model\mongo\MongoKsPicDayReportModel',
            ],

            'stat' => [
                self::STAT_ACCOUNT => '\app\model\mongo\MongoKsAccountVideoStatModel',
                self::STAT_CLIENT => '\app\model\mongo\MongoKsClientVideoStatModel',
                self::STAT_KS_USER_VIDEO => '\app\model\mongo\MongoKsUserVideoStatModel',
                self::STAT_VIDEO => '\app\model\mongo\MongoKsVideoStatModel',
            ],

            'pic_stat' => [
                self::STAT_ACCOUNT => '\app\model\mongo\MongoKsAccountPicStatModel',
                self::STAT_CLIENT => '\app\model\mongo\MongoKsClientPicStatModel',
                // self::STAT_KS_USER_VIDEO => '\app\model\MongoKsUserPicStatModel',
                self::STAT_PICTURE => '\app\model\mongo\MongoKsPicStatModel',
            ],

            'account_stat' => [
                self::STAT_CLIENT => '\app\model\mongo\MongoClientAccountTypeDayStatModel',
                self::STAT_PRODUCT => '\app\model\mongo\MongoProductAccountTypeDayStatModel',
                self::STAT_MONTH => '\app\model\mongo\MongoClientMonthStatModel',
                self::STAT_CLIENT_MEDIA => '\app\model\mongo\MongoClientMediaMonthStatModel',
            ],

            'sync' => [
                'account' => '\app\model\mongo\MongoKsAccountSyncLogModel',
                'video' => '\app\model\mongo\MongoKsVideoSyncLogModel',
                'pic' => '\app\model\mongo\MongoKsPicSyncLogModel',
            ],

            'sync_append' => [
                'video' => '\app\model\mongo\MongoKsVideoAppendSyncLogModel',
                'pic' => '\app\model\mongo\MongoKsPicAppendSyncLogModel',
            ],

            'info' => [
                'video' => '\app\model\mongo\MongoKsUserVideoModel',
                'pic' => '\app\model\mongo\MongoKsPicModel',
            ],
        ],

        CommonEnum::QQ_MEDIA => [
            'report' => [
                self::TASK_TYPE_ACCOUNT => '\app\model\mongo\MongoQqAccountDayReportModel',
                self::TASK_TYPE_VIDEO => '\app\model\mongo\MongoQqVideoDayReportModel',
                self::TASK_TYPE_PICTURE => '\app\model\mongo\MongoQqPicDayReportModel',
            ],

            'stat' => [
                self::STAT_ACCOUNT => '\app\model\mongo\MongoQqAccountVideoStatModel',
                self::STAT_CLIENT => '\app\model\mongo\MongoQqClientVideoStatModel',
                self::STAT_VIDEO => '\app\model\mongo\MongoQqVideoStatModel',
            ],

            'pic_stat' => [
                self::STAT_ACCOUNT => '\app\model\mongo\MongoQqAccountPicStatModel',
                self::STAT_CLIENT => '\app\model\mongo\MongoQqClientPicStatModel',
                self::STAT_VIDEO => '\app\model\mongo\MongoQqPicStatModel',
            ],

            'account_stat' => [
                self::STAT_CLIENT => '\app\model\mongo\MongoClientAccountTypeDayStatModel',
                self::STAT_PRODUCT => '\app\model\mongo\MongoProductAccountTypeDayStatModel',
                self::STAT_MONTH => '\app\model\mongo\MongoClientMonthStatModel',
                self::STAT_CLIENT_MEDIA => '\app\model\mongo\MongoClientMediaMonthStatModel',
            ],

            'sync' => [
                'account' => '\app\model\mongo\MongoQqAccountSyncLogModel',
                'video' => '\app\model\mongo\MongoQqVideoSyncLogModel',
                'pic' => '\app\model\mongo\MongoQqPicSyncLogModel',
            ],

            'sync_append' => [
                'video' => '\app\model\mongo\MongoQqVideoAppendSyncLogModel',
                'pic' => '\app\model\mongo\MongoQqPicAppendSyncLogModel',
            ],

            'info' => [
                'video' => '\app\model\mongo\MongoQqVideoModel',
                'pic' => '\app\model\mongo\MongoQqPicModel',
            ],
        ],
    ];

    /**
     * @var array 服务列表列表
     */
    private const CLASS_SERVICE_LIST = [
        CommonEnum::OE_MEDIA => [
            'sync' => [
                self::TASK_TYPE_ACCOUNT => '\app\service\cdc\sync\account\OeAccountSyncLogService',
                self::TASK_TYPE_VIDEO => '\app\service\cdc\sync\video\OeVideoSyncLogService',
                self::TASK_TYPE_PICTURE => '\app\service\cdc\sync\pic\OePicSyncLogService',
            ],
            'stat' => [
                self::TASK_TYPE_ACCOUNT => '\app\service\cdc\stat\account\OceanAccountService',
                self::TASK_TYPE_VIDEO => '\app\service\cdc\stat\OceanVideoService',
                self::TASK_TYPE_PICTURE => '\app\service\cdc\stat\OceanPicService',
            ],
        ],

        CommonEnum::KS_MEDIA => [
            'sync' => [
                self::TASK_TYPE_ACCOUNT => '\app\service\cdc\sync\account\KsAccountSyncLogService',
                self::TASK_TYPE_VIDEO => '\app\service\cdc\sync\video\KsVideoSyncLogService',
                self::TASK_TYPE_PICTURE => '\app\service\cdc\sync\pic\KsPicSyncLogService',
            ],
            'stat' => [
                self::TASK_TYPE_ACCOUNT => '\app\service\cdc\stat\account\KsAccountService',
                self::TASK_TYPE_VIDEO => '\app\service\cdc\stat\KsVideoService',
                self::TASK_TYPE_PICTURE => '\app\service\cdc\stat\KsPicService',
            ],
        ],

        CommonEnum::QQ_MEDIA => [
            'sync' => [
                self::TASK_TYPE_ACCOUNT => '\app\service\cdc\sync\account\QqAccountSyncLogService',
                self::TASK_TYPE_VIDEO => '\app\service\cdc\sync\video\QqVideoSyncLogService',
                self::TASK_TYPE_PICTURE => '\app\service\cdc\sync\pic\QqPicSyncLogService',
            ],
            'stat' => [
                self::TASK_TYPE_ACCOUNT => '\app\service\cdc\stat\account\QqAccountService',
                self::TASK_TYPE_VIDEO => '\app\service\cdc\stat\QqVideoService',
                self::TASK_TYPE_PICTURE => '\app\service\cdc\stat\QqPicService',
            ],
        ],
    ];

    /**
     * 获取类名.
     *
     * @param int $mediaId 媒体id
     * @param mixed ...$args 类型
     * @return mixed|string
     */
    public static function getClassNames(int $mediaId = 0, ...$args)
    {
        $name = self::CLASS_LIST[$mediaId];
        foreach ($args as $v) {
            if (! is_array($name) || is_array($v)) {
                break;
            }
            $name = $name[$v] ?? '';
        }
        return $name;
    }

    /**
     * 获取服务类名.
     *
     * @param int $mediaId 媒体id
     * @param mixed ...$args 类型
     * @return mixed|string|string[]|string[][]
     */
    public static function getServiceClassNames(int $mediaId = 0, ...$args)
    {
        $name = self::CLASS_SERVICE_LIST[$mediaId];
        foreach ($args as $v) {
            if (! is_array($name) || is_array($v)) {
                break;
            }
            $name = $name[$v] ?? '';
        }
        return $name;
    }
}
